{% comment %}
/* Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
{% endcomment %}
{% extends 'admin_base.html' %}
{% block content %}
  {% if do_import %}
  <div id="edit-message">
    {% if confirmation %}
      <div class="success">Feed successfully imported!</div>
    {% else %}
      <div class="warning">Warning, there were errors: {{ warnings }}</div>
    {% endif %}
  </div>
  {% endif %}

  {% if parsed_feed %}
    <div class="table">
      <div class="row">
        <div class="cell label">
          Feed title:
        </div>
        <div class="cell input">
          {{parsed_feed.feed.title|escape}}
        </div>
      </div>
      {% for entry in parsed_feed.entries%}
      <div class="row">
        <div class="cell label">Post Title:</div>
        <div class="cell input">{{entry.title|escape}}</div>
      </div>
      <div class="row">
        <div class="cell label">Post Link:</div> 
        <div class="cell input">{{entry.link|escape}}</div>    
      </div>  
        {% if entry.feedburner_origlink %}
      <div class="row">
        <div class="cell label">Non-Feedburner Link:</div>
        <div class="cell input">{{entry.feedburner_origlink|escape}}</div>
      </div>
        {% endif %}
      <div class="row">
        <div class="cell"></div>
        <div class="cell input">
        {% for contents in entry.content %}
        <h3>Contents:</h3>
        <div>{{contents.value|escape}}</div>
        {% endfor %}
        </div>
      </div>
    </div>
    {% endfor %}
    <form method="POST">
      <input type="hidden" name="author" value="{{user.key}}">
      <input type="hidden" name="feedURL" value="{{feedURL}}" />
      <input type="hidden" name="import_type" value="{{import_type}}" />
      <input type="hidden" name="path_prefix" value="{{path_prefix}}" />
      
      <div class="table">
        <div class="row">
          <div class="cell label">
            <input type="submit" name="cancel" value="Cancel" />
          </div>
          <div class="cell input">
            <input type="submit" name="do_import" value="Import Feed" />
          </div>
        </div>
      </div>
    </form>    
  {% else %}
  <h3>Import an ATOM or RSS feed to become Posts or Pages</h3>
  <form method="POST">
    <input type="hidden" name="author" value="{{user.key}}">
    <div class="table">
      <div class="row">
        <div class="cell label">URL of the feed:</div>
        <div class="cell input">
          <input type="text" size="75" name="feedURL" value="{{feedURL}}" />
        </div>
      </div>
      <div class="row">
        <div class="cell label">Path prefix:</div>
        <div class="cell input">
          <input
            type="text"
            size="15"
            name="path_prefix"
            value="{{path_prefix}}" /><br>(optional value to insert before the path of new entries)
        </div>
      </div>
      <div class="row">
        <div class="cell label">Import type:</div>
        <div class="cell input">
          <input
            type="radio"
            name="import_type"
            value="post"
            checked="checked"
            id="import_post"/> <label for="import_post">Posts</label>
          <input
            type="radio"
            name="import_type"
            value="pages"
            id="import_page"/> <label for="import_page">Pages</label>
        </div>
      </div>
      <div class="row">
        <div class="cell label">
          <input type="submit" name="preview" value="Preview" />
        </div>
        <div class="cell input">
          <input type="submit" name="do_import" value="I'm feeling lucky" />
        </div>
      </div>
    </div>
  </form>
  {% endif %}
{% endblock %}